package com.atguigu.zy.interview.juc.single;

/**
 * @Author : Jungle
 * @Description :  恶汉式
 *
 * 饿汉式的⽅式只要Singleton类被装载了，那么uniqueInstance就会被实例化（没有达到lazy loading效果），⽽这
 * 种⽅式是Singleton类被装载了，uniqueInstance不⼀定被初始化。因为SingletonHolder类没有被主动使⽤，只有
 * 显示通过调⽤getInstance⽅法时，才会显式装载SingletonHolder类，从⽽实例化uniqueInstance
 */
public class StaticInnerClassSingletonDemo {
    private static class SingletonHolder {
        private static StaticInnerClassSingletonDemo uniqueInstance = new StaticInnerClassSingletonDemo();

    }

    private StaticInnerClassSingletonDemo() {
    }

    public static StaticInnerClassSingletonDemo getInstance() {
        return SingletonHolder.uniqueInstance;
    }
}
